<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

</html>
<script>
    var p = new Promise((resolve, reject) => {
        setTimeout(() => {
            // resolve(888888);
            reject(6666666);
        }, 4000)
    })
    //当Promise对象的状态变为 finished 成功时, 会立即执行then和finally的回调
    p.then((res) => {
        console.log("Promise对象的状态变为 finished 成功", res);
    })
        //当Promise对象的状态变为 rejected 失败时, 会立即执行catch和finally的回调
        .catch((err) => {
            console.log('Promise对象的状态变为 rejected 失败', err);
        })
        //不论最终Promise对象的状态是 finished 还是 rejected , finally的回调都会执行
        .finally(() => {
            console.log("Promise对象的状态终止(结束)");
        }) 
</script>